#include "MutaTimer.h"

MutaTimer::MutaTimer(int interval) :
    QThread(),
    interval(interval),
    playing(false)
{

}

void MutaTimer::start(QThread::Priority priority)
{
    QThread::start(priority);
}

void MutaTimer::run()
{
    while(true) {
        if(playing) {
            emit timeout(elapsedTimer.restart());
            msleep(interval);
        } else {
            msleep(interval*10);
        }

    }
}

void MutaTimer::setPlaying(bool playing)
{
    this->playing = playing;
}
void MutaTimer::startPlaying()
{
    playing = true;
    elapsedTimer.restart();
}
void MutaTimer::stopPlaying()
{
    playing = false;
    elapsedTimer.restart();
}
